*
* A minimal main program for a threaded GTK+ application
* looks like:
- * |[
+ * |[<!-- language="C" -->
* int
* main (int argc, char *argv[])
* {
*
* Erik Mouw contributed the following code example to
* illustrate how to use threads within GTK+ programs.
- * |[
+ * |[<!-- language="C" -->
* /<!---->*-------------------------------------------------------------------------
* * Filename: gtk-thread.c
* * Version: 0.99.1
* running in thread A and accessing @self after it has been finalized
* in thread B:
*
- * |[
+ * |[<!-- language="C" -->
* static gboolean
* idle_callback (gpointer data)
* {
* This variant of g_timeout_add_full() can be thought of a MT-safe version
* for GTK+ widgets for the following use case:
*
- * |[
+ * |[<!-- language="C" -->
* static gboolean timeout_callback (gpointer data)
* {
* SomeWidget *self = data;
* screen or workspace.
* <example>
* <title>Launching an application</title>
- * |[
+ * |[<!-- language="C" -->
* GdkAppLaunchContext *context;
*
* context = gdk_display_get_app_launch_context (display);
*
* <example>
* <title>Trapping an X error</title>
- * |[
+ * |[<!-- language="C" -->
* gdk_error_trap_push (<!-- -->);
*
* // ... Call the X function which may cause an error here ...
*
* <example id="backend-specific">
* <title>Backend-specific code</title>
- * |[
+ * |[<!-- language="C" -->
* #ifdef GDK_WINDOWING_X11
* if (GDK_IS_X11_DISPLAY (display))
* {
* By default, GDK tries all included backends.
*
* For example,
- * |[
+ * |[<!-- language="C" -->
* gdk_set_allowed_backends ("wayland,quartz,*");
* ]|
* instructs GDK to try the Wayland backend first,
* core pointer. Coordinate extraction, processing and requesting more
* motion events from a %GDK_MOTION_NOTIFY event usually works like this:
*
- * |[
+ * |[<!-- language="C" -->
* {
* /* motion_event handler */
* x = motion_event->x;
* The event type is always the first field in all of the event types, and
* can always be accessed with the following code, no matter what type of
* event it is:
- * |[
+ * |[<!-- language="C" -->
* GdkEvent *event;
* GdkEventType type;
*
* can be cast to the appropriate event type, or the union member
* name can be used. For example if the event type is %GDK_BUTTON_PRESS
* then the x coordinate of the button press can be accessed with:
- * |[
+ * |[<!-- language="C" -->
* GdkEvent *event;
* gdouble x;
*
* x = ((GdkEventButton*)event)->x;
* ]|
* or:
- * |[
+ * |[<!-- language="C" -->
* GdkEvent *event;
* gdouble x;
*
* <literal><Control>plus</literal> accelerator <Shift> should
* be masked out.
* </para>
- * |[
+ * |[<!-- language="C" -->
* /* We want to ignore irrelevant modifiers like ScrollLock */
* #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)
* gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
* all modifiers that might affect the translation of the key;
* this allowed accelerators to be stored with irrelevant consumed
* modifiers, by doing:</para>
- * |[
+ * |[<!-- language="C" -->
* /* XXX Don't do this XXX */
* if (keyval == accel_keyval &&
* (event->state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
* <title>Draw transformed text with Pango and cairo</title>
* <!-- Note that this example is basically the same as
* demos/gtk-demo/rotated_text.c -->
- * |[
+ * |[<!-- language="C" -->
* #define RADIUS 100
* #define N_WORDS 10
* #define FONT "Sans Bold 18"
* Here's an example of how the terminal example would be implemented, assuming
* a terminal area widget called "terminal" and a toplevel window "toplevel":
*
- * |[
+ * |[<!-- language="C" -->
* GdkGeometry hints;
*
* hints.base_width = terminal->char_width;
* calls by an ifdef as follows. Since GDK may be built with multiple
* backends, you should also check for the backend that is in use (e.g. by
* using the GDK_IS_WAYLAND_DISPLAY() macro).
- * |[
+ * |[<!-- language="C" -->
* #ifdef GDK_WINDOWING_WAYLAND
* if (GDK_IS_WAYLAND_DISPLAY (display))
* {
* This function should be called before a #GdkWindow is shown. This is
* best done by connecting to the #GtkWidget::realize signal:
*
- * |[
+ * |[<!-- language="C" -->
* static void
* widget_realize_cb (GtkWidget *widget)
* {
* </para>
* <example>
* <title>A class fragment implementing #GtkActivatable</title>
- * |[
+ * |[<!-- language="C" -->
*
* enum {
* ...
* to the group.
*
* A common way to set up a group of radio group is the following:
- * |[
+ * |[<!-- language="C" -->
* GSList *group = NULL;
* GtkRadioAction *action;
*
* and gtk_radio_action_set_group() methods
*
* A common way to set up a group of radio actions is the following:
- * |[
+ * |[<!-- language="C" -->
* GtkRadioAction *action;
* GtkRadioAction *last_action;
*
* <literal>*</literal>. So for example, the following specifies different icons to
* use for left-to-right and right-to-left languages:
*
- * |[
+ * |[<!-- language="C" -->
* stock["my-stock-item"] =
* {
* { "itemltr.png", LTR, *, * },
*
* This could be abbreviated as follows:
*
- * |[
+ * |[<!-- language="C" -->
* stock["my-stock-item"] =
* {
* { "itemltr.png", LTR },
*
* You can specify custom icons for specific sizes, as follows:
*
- * |[
+ * |[<!-- language="C" -->
* stock["my-stock-item"] =
* {
* { "itemmenusize.png", *, *, "gtk-menu" },
*
* It's also possible to use custom icons for a given state, for example:
*
- * |[
+ * |[<!-- language="C" -->
* stock["my-stock-item"] =
* {
* { "itemprelight.png", *, PRELIGHT },
* would be items inside a GNOME canvas widget.
*
* The action of gtk_rc_get_style() is similar to:
- * |[
+ * |[<!-- language="C" -->
* gtk_widget_path (widget, NULL, &path, NULL);
* gtk_widget_class_path (widget, NULL, &class_path, NULL);
* gtk_rc_get_style_by_paths (gtk_widget_get_settings (widget),
* the correct domain when calling dgettext(). This can be useful, e.g.
* when dealing with message contexts:
*
- * |[
+ * |[<!-- language="C" -->
* GtkStockItem items[] = {
* { MY_ITEM1, NC_("odd items", "Item 1"), 0, 0, "odd-item-domain" },
* { MY_ITEM2, NC_("even items", "Item 2"), 0, 0, "even-item-domain" },
* UI in an idle function. A typical example where this function is
* useful is to enforce that the menubar and toolbar have been added to
* the main window before showing it:
- * |[
+ * |[<!-- language="C" -->
* gtk_container_add (GTK_CONTAINER (window), vbox);
* g_signal_connect (merge, "add-widget",
* G_CALLBACK (add_widget), vbox);
* from #GtkBox, and set the #GtkOrientable:orientation property to
* %GTK_ORIENTATION_VERTICAL in your instance init function, with a
* call like:
- * |[
+ * |[<!-- language="C" -->
* gtk_orientable_set_orientation (GTK_ORIENTABLE (object),
* GTK_ORIENTATION_VERTICAL);
* ]|
* application, but in order to ensure proper translation of the title,
* applications should set the title property explicitly when constructing
* a GtkAboutDialog, as shown in the following example:
- * |[
+ * |[<!-- language="C" -->
* gtk_show_about_dialog (NULL,
* "program-name", "ExampleCode",
* "logo", example_logo,
* of the language which is currently used in the user interface.
* Using gettext(), a simple way to achieve that is to mark the
* string for translation:
- * |[
+ * |[<!-- language="C" -->
* gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
* ]|
* It is a good idea to use the customary msgid "translator-credits" for this
* though it is almost always used to display just one accelerator key.
* <example>
* <title>Creating a simple menu item with an accelerator key.</title>
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *save_item;
* GtkAccelGroup *accel_group;
*
* </figure>
*
* <example id="gtkapplication"><title>A simple application</title>
- * |[
+ * |[<!-- language="C" -->
* <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/bloatpad.c">
* <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
* </xi:include>
* using gtk_header_bar_set_show_close_button().
*
* <example><title>A GtkApplicationWindow with a menubar</title>
- * |[
+ * |[<!-- language="C" -->
* app = gtk_application_new ();
*
* builder = gtk_builder_new ();
* </example>
*
* <example><title>Handling fallback yourself</title>
- * |[
+ * |[<!-- language="C" -->
* <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/sunny.c">
* <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
* </xi:include>
* of a #GtkTreeModel one would do the following:
* <example>
* <title>Requesting the width of a handful of GtkTreeModel rows</title>
- * |[
+ * |[<!-- language="C" -->
* GtkTreeIter iter;
* gint minimum_width;
* gint natural_width;
* take up the full width of the layouting widget would look like:
* <example>
* <title>A typical get_preferred_width(<!-- -->) implementation</title>
- * |[
+ * |[<!-- language="C" -->
* static void
* foo_get_preferred_width (GtkWidget *widget,
* gint *minimum_size,
* root level of a #GtkTreeModel one would do the following:
* <example>
* <title>Requesting the height for width of a handful of GtkTreeModel rows</title>
- * |[
+ * |[<!-- language="C" -->
* GtkTreeIter iter;
* gint minimum_height;
* gint natural_height;
* runs as follows:
* <example>
* <title>Requesting the width of a handful of GtkTreeModel rows</title>
- * |[
+ * |[<!-- language="C" -->
* GtkAllocation allocation;
* GdkRectangle cell_area = { 0, };
* GtkTreeIter iter;
* should be implemented:
* <example>
* <title>Implementing keyboard focus navigation</title>
- * |[
+ * |[<!-- language="C" -->
* static gboolean
* foo_focus (GtkWidget *widget,
* GtkDirectionType direction)
* to the fact that these widgets internally use a #GtkCellArea.
* The cell area is exposed as a construct-only property by these
* widgets. This means that it is possible to e.g. do
- * |[
+ * |[<!-- language="C" -->
* combo = g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL);
* ]|
* to use a custom cell area with a combo box. But construct properties
* cause the default cell area to be instantiated. In this case, a provided
* construct property value will be ignored (with a warning, to alert
* you to the problem).
- * |[
+ * |[<!-- language="C" -->
* static void
* my_combo_box_init (MyComboBox *b)
* {
* continue to use the same kind of widget for editing in future
* releases, therefore you should check the type of @editable
* before doing any specific setup, as in the following example:
- * |[
+ * |[<!-- language="C" -->
* static void
* text_editing_started (GtkCellRenderer *cell,
* GtkCellEditable *editable,
*
* Here's an example signal handler which fetches data from the model and
* displays it in the entry.
- * |[
+ * |[<!-- language="C" -->
* static gchar*
* format_entry_text_callback (GtkComboBox *combo,
* const gchar *path,
* the container must return the height for its minimum width. This is easily achieved by
* simply calling the reverse apis implemented for itself as follows:
*
- * |[
+ * |[<!-- language="C" -->
* static void
* foo_container_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
* {
* Similarly, when gtk_widget_get_preferred_width_for_height() is called for a container or widget
* that is height-for-width, it then only needs to return the base minimum width like so:
*
- * |[
+ * |[<!-- language="C" -->
* static void
* foo_container_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
* gint *min_width, gint *nat_width)
* in the dialog.
* <example>
* <title>Simple GtkDialog usage</title>
- * |[
+ * |[<!-- language="C" -->
* /* Function to open a dialog box displaying the message provided. */
* void
* quick_message (gchar *message)
* so the first button in the list will be the leftmost button in the dialog.
*
* Here's a simple example:
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *dialog = gtk_dialog_new_with_buttons ("My dialog",
* main_app_window,
* GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
* destroying the dialog if you wish to do so.
*
* Typical usage of this function might be:
- * |[
+ * |[<!-- language="C" -->
* gint result = gtk_dialog_run (GTK_DIALOG (dialog));
* switch (result)
* {
*
* Use this function after adding all the buttons to your dialog, as the
* following example shows:
- * |[
+ * |[<!-- language="C" -->
* cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
* _("_Cancel"),
* GTK_RESPONSE_CANCEL);
* There's no way to set a default action here, you can use the
* #GtkWidget::drag-motion callback for that. Here's an example which selects
* the action to use depending on whether the control key is pressed or not:
- * |[
+ * |[<!-- language="C" -->
* static void
* drag_motion (GtkWidget *widget,
* GdkDragContext *context,
*
* <example>
* <title>Simple GtkDrawingArea usage</title>
- * |[
+ * |[<!-- language="C" -->
* gboolean
* draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data)
* {
*
* <example>
* <title>Forcing entry to uppercase.</title>
- * |[
+ * |[<!-- language="C" -->
* #include <ctype.h>
*
* void
*
* This is equivalent to:
*
- * |[
+ * |[<!-- language="C" -->
* gtk_entry_buffer_get_text (gtk_entry_get_buffer (entry));
* ]|
*
*
* This is equivalent to:
*
- * |[
+ * |[<!-- language="C" -->
* gtk_entry_buffer_set_max_length (gtk_entry_get_buffer (entry), max);
* ]|
**/
*
* This is equivalent to:
*
- * |[
+ * |[<!-- language="C" -->
* gtk_entry_buffer_get_max_length (gtk_entry_get_buffer (entry));
* ]|
*
*
* This is equivalent to:
*
- * |[
+ * |[<!-- language="C" -->
* gtk_entry_buffer_get_length (gtk_entry_get_buffer (entry));
* ]|
*
* its expansion state. You should watch this property with a signal
* connection as follows:
* </para>
- * |[
+ * |[<!-- language="C" -->
* expander = gtk_expander_new_with_mnemonic ("_More Options");
* g_signal_connect (expander, "notify::expanded",
* G_CALLBACK (expander_callback), NULL);
* </para>
* <example id="example-gtkfilechooser-preview">
* <title>Sample Usage</title>
- * |[
+ * |[<!-- language="C" -->
* {
* GtkImage *preview;
*
* </para>
* <example id="example-gtkfilechooser-extra">
* <title>Sample Usage</title>
- * |[
+ * |[<!-- language="C" -->
*
* GtkWidget *toggle;
*
* illustrates this.
* <example id="gtkfilechooser-confirmation">
* <title>Custom confirmation</title>
- * |[
+ * |[<!-- language="C" -->
* static GtkFileChooserConfirmation
* confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
* {
* a modified version. If you don't have a file name already — for
* example, if the user just created a new file and is saving it for the first
* time, do not call this function. Instead, use something similar to this:
- * |[
+ * |[<!-- language="C" -->
* if (document_is_new)
* {
* /* the user just created a new document */
* modified version. If you don't have a file name already — for example,
* if the user just created a new file and is saving it for the first time, do
* not call this function. Instead, use something similar to this:
- * |[
+ * |[<!-- language="C" -->
* if (document_is_new)
* {
* /* the user just created a new document */
* a file name already — for example, if the user just created a new
* file and is saving it for the first time, do not call this function.
* Instead, use something similar to this:
- * |[
+ * |[<!-- language="C" -->
* if (document_is_new)
* {
* /* the user just created a new document */
*
* <example>
* <title>Create a button to let the user select a file in /etc</title>
- * |[
+ * |[<!-- language="C" -->
* {
* GtkWidget *button;
*
* gtk_file_filter_add_mime_type(), gtk_file_filter_add_pattern(),
* or gtk_file_filter_add_custom(). To create a filter
* that accepts any file, use:
- * |[
+ * |[<!-- language="C" -->
* GtkFileFilter *filter = gtk_file_filter_new ();
* gtk_file_filter_add_pattern (filter, "*");
* ]|
* so that the icon information is shared with other people
* looking up icons. In the case where the default screen is
* being used, looking up an icon can be as simple as:
- * |[
+ * |[<!-- language="C" -->
* GError *error = NULL;
* GtkIconTheme *icon_theme;
* GdkPixbuf *pixbuf;
* To do this, you can use gtk_tree_row_reference_new().
*
* To free the return value, use:
- * |[
+ * |[<!-- language="C" -->
* g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
* ]|
*
* #GdkPixbuf ("pixel buffer") from a file, and then display that.
* There's a convenience function to do this, gtk_image_new_from_file(),
* used as follows:
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *image;
* image = gtk_image_new_from_file ("myfile.png");
* ]|
* #GtkEventBox, then connect to the event signals on the event box.
* <example>
* <title>Handling button press events on a #GtkImage.</title>
- * |[
+ * |[<!-- language="C" -->
* static gboolean
* button_press_callback (GtkWidget *event_box,
* GdkEventButton *event,
* implements a subclass of #GtkIMContext or #GtkIMContextSimple and exports
* these four functions:
*
- * |[
+ * |[<!-- language="C" -->
* void im_module_init(#GTypeModule *module);
* ]|
* This function should register the #GType of the #GtkIMContext subclass which
* that g_type_register_static() cannot be used as the type needs to be
* registered dynamically.
*
- * |[
+ * |[<!-- language="C" -->
* void im_module_exit(void);
* ]|
* Here goes any cleanup code your input method might require on module unload.
*
- * |[
+ * |[<!-- language="C" -->
* void im_module_list(const #GtkIMContextInfo ***contexts, int *n_contexts)
* {
* *contexts = info_list;
* pointer to statically defined array of #GtkIMContextInfo items for each
* provided input method.
*
- * |[
+ * |[<!-- language="C" -->
* #GtkIMContext * im_module_create(const #gchar *context_id);
* ]|
* This function should return a pointer to a newly created instance of the
*
* <example>
* <title>Simple GtkInfoBar usage.</title>
- * |[
+ * |[<!-- language="C" -->
* /* set up info bar */
* info_bar = gtk_info_bar_new ();
* gtk_widget_set_no_show_all (info_bar, TRUE);
* using gtk_label_set_mnemonic_widget(). Here's a simple example where
* the label is inside a button:
*
- * |[
+ * |[<!-- language="C" -->
* // Pressing Alt+H will activate this button
* button = gtk_button_new (<!-- -->);
* label = gtk_label_new_with_mnemonic ("_Hello");
* There's a convenience function to create buttons with a mnemonic label
* already inside:
*
- * |[
+ * |[<!-- language="C" -->
* // Pressing Alt+H will activate this button
* button = gtk_button_new_with_mnemonic ("_Hello");
* ]|
* #GtkEntry, you have to point the label at the entry with
* gtk_label_set_mnemonic_widget():
*
- * |[
+ * |[<!-- language="C" -->
* // Pressing Alt+H will focus the entry
* entry = gtk_entry_new (<!-- -->);
* label = gtk_label_new_with_mnemonic ("_Hello");
* linkend="PangoMarkupFormat">markup format</link>.
* Here's how to create a label with a small font:
*
- * |[
+ * |[<!-- language="C" -->
* label = gtk_label_new (NULL);
* gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
* ]|
* way they appear in web browsers, with colored, underlined text. The title
* attribute is displayed as a tooltip on the link. An example looks like this:
*
- * |[
+ * |[<!-- language="C" -->
* gtk_label_set_markup (label, "Go to the <a href="http://www.gtk.org" title="<i>Our</i> website">GTK+ website</a> for more...");
* ]|
*
* label's text and attribute list based on the parse results. If the @str is
* external data, you may need to escape it with g_markup_escape_text() or
* g_markup_printf_escaped()<!-- -->:
- * |[
+ * |[<!-- language="C" -->
* char *markup;
*
* markup = g_markup_printf_escaped ("<span style=\"italic\">%s</span>", str);
*
* <example>
* <title>Adding a custom offset on the bar</title>
- * |[
+ * |[<!-- language="C" -->
*
* static GtkWidget *
* create_level_bar (void)
*
* <example>
* <title>Creating a simple list store.</title>
- * |[
+ * |[<!-- language="C" -->
* enum {
* COLUMN_STRING,
* COLUMN_INT,
*
* <example>
* <title>A UI Definition fragment for a list store</title>
- * |[
+ * |[<!-- language="C" -->
* <object class="GtkListStore">
* <columns>
* <column type="gchararray"/>
* Calling
* <literal>gtk_list_store_insert_with_values (list_store, iter, position...)</literal>
* has the same effect as calling
- * |[
+ * |[<!-- language="C" -->
* gtk_list_store_insert (list_store, iter, position);
* gtk_list_store_set (list_store, iter, ...);
* ]|
* </para>
* <example>
* <title>Typical main() function for a GTK+ application</title>
- * |[
+ * |[<!-- language="C" -->
* int
* main (int argc, char **argv)
* {
* changed after GTK+ has already been initialized. In this case,
* you can use it to update the default text direction as follows:
*
- * |[
+ * |[<!-- language="C" -->
* setlocale (LC_ALL, new_locale);
* direction = gtk_get_locale_direction ();
* gtk_widget_set_default_direction (direction);
*
* <example>
* <title>Updating the UI during a long computation</title>
- * |[
+ * |[<!-- language="C" -->
* /* computation going on... */
*
* while (gtk_events_pending ())
*
* <example>
* <title>A persistent window</title>
- * |[
+ * |[<!-- language="C" -->
* #include <gtk/gtk.h><
*
* int
*
* <example>
* <title>Connecting the popup signal handler.</title>
- * |[
+ * |[<!-- language="C" -->
* /<!---->* connect our handler which will popup the menu *<!---->/
* g_signal_connect_swapped (window, "button_press_event",
* G_CALLBACK (my_popup_handler), menu);
*
* <example>
* <title>Signal handler which displays a popup menu.</title>
- * |[
+ * |[<!-- language="C" -->
* static gint
* my_popup_handler (GtkWidget *widget, GdkEvent *event)
* {
*
* <example>
* <title>Setting markup and accelerator on a MenuItem</title>
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *child = gtk_bin_get_child (GTK_BIN (menu_item));
* gtk_label_set_markup (GTK_LABEL (child), "<i>new label</i> with <b>markup</b>");
* gtk_accel_label_set_accel (GTK_ACCEL_LABEL (child), GDK_KEY_1, 0);
* returns when any dialog button is clicked.
* <example>
* <title>A modal dialog.</title>
- * |[
+ * |[<!-- language="C" -->
* dialog = gtk_message_dialog_new (main_application_window,
* GTK_DIALOG_DESTROY_WITH_PARENT,
* GTK_MESSAGE_ERROR,
* You might do a non-modal #GtkMessageDialog as follows:
* <example>
* <title>A non-modal dialog.</title>
- * |[
+ * |[<!-- language="C" -->
* dialog = gtk_message_dialog_new (main_application_window,
* GTK_DIALOG_DESTROY_WITH_PARENT,
* GTK_MESSAGE_ERROR,
* instead, since you can't pass the markup string either
* as the format (it might contain '%' characters) or as a string
* argument.
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *dialog;
* dialog = gtk_message_dialog_new (main_application_window,
* GTK_DIALOG_DESTROY_WITH_PARENT,
* may contain special XML characters, you should use g_markup_printf_escaped()
* to escape it.
- * |[
+ * |[<!-- language="C" -->
* gchar *msg;
*
* msg = g_markup_printf_escaped (message_format, ...);
* destination and accept the target "GTK_NOTEBOOK_TAB". The notebook
* will fill the selection with a GtkWidget** pointing to the child
* widget that corresponds to the dropped tab.
- * |[
+ * |[<!-- language="C" -->
* static void
* on_drop_zone_drag_data_received (GtkWidget *widget,
* GdkDragContext *context,
*
* <example>
* <title>A page setup dialog</title>
- * |[
+ * |[<!-- language="C" -->
* static GtkPrintSettings *settings = NULL;
* static GtkPageSetup *page_setup = NULL;
*
*
* <example>
* <title>Creating a paned widget with minimum sizes.</title>
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
* GtkWidget *frame1 = gtk_frame_new (NULL);
* GtkWidget *frame2 = gtk_frame_new (NULL);
* A #GSList of #GFile of the locations that have been added as
* application-specific shortcuts with gtk_places_sidebar_add_shortcut().
* To free this list, you can use
- * |[
+ * |[<!-- language="C" -->
* g_slist_free_full (list, (GDestroyNotify) g_object_unref);
* ]|
*
*
* <example>
* <title>Using GtkPrintContext in a #GtkPrintOperation::draw-page callback</title>
- * |[
+ * |[<!-- language="C" -->
* static void
* draw_page (GtkPrintOperation *operation,
* GtkPrintContext *context,
*
* <example>
* <title>The high-level printing API</title>
- * |[
+ * |[<!-- language="C" -->
* static GtkPrintSettings *settings = NULL;
*
* static void
* Emitted for every page that is printed. The signal handler
* must render the @page_nr's page onto the cairo context obtained
* from @context using gtk_print_context_get_cairo_context().
- * |[
+ * |[<!-- language="C" -->
* static void
* draw_page (GtkPrintOperation *operation,
* GtkPrintContext *context,
* #GtkPrintOperation::done signal will be emitted with the result of the
* operation when the it is done (i.e. when the dialog is canceled, or when
* the print succeeds or fails).
- * |[
+ * |[<!-- language="C" -->
* if (settings != NULL)
* gtk_print_operation_set_print_settings (print, settings);
*
*
* <example>
* <title>How to create a group of two radio buttons.</title>
- * |[
+ * |[<!-- language="C" -->
* void create_radio_buttons (void) {
*
* GtkWidget *window, *radio1, *radio2, *box, *entry;
* and gtk_radio_button_set_group() methods
*
* A common way to set up a group of radio buttons is the following:
- * |[
+ * |[<!-- language="C" -->
* GtkRadioButton *radio_button;
* GtkRadioButton *last_button;
*
*
* <example>
* <title>How to create a group of radio menu items.</title>
- * |[
+ * |[<!-- language="C" -->
* GSList *group = NULL;
* GtkWidget *item;
* gint i;
* <title>Typical usage</title>
* In the simplest of cases, you can use the following code to use
* a #GtkRecentChooserDialog to select a recently used file:
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *dialog;
*
* dialog = gtk_recent_chooser_dialog_new ("Recent Documents",
* gtk_recent_filter_add_pattern(), gtk_recent_filter_add_mime_type(),
* gtk_recent_filter_add_application(), gtk_recent_filter_add_age().
* To create a filter that accepts any recently used resource, use:
- * |[
+ * |[<!-- language="C" -->
* GtkRecentFilter *filter = gtk_recent_filter_new ();
* gtk_recent_filter_add_pattern (filter, "*");
* ]|
*
* Adding a new recently used file is as simple as:
*
- * |[
+ * |[<!-- language="C" -->
* GtkRecentManager *manager;
*
* manager = gtk_recent_manager_get_default ();
* Looking up the meta-data associated with a recently used file
* given its URI requires calling gtk_recent_manager_lookup_item():
*
- * |[
+ * |[<!-- language="C" -->
* GtkRecentManager *manager;
* GtkRecentInfo *info;
* GError *error = NULL;
*
* Here's an example signal handler which displays a value 1.0 as
* with "-->1.0<--".
- * |[
+ * |[<!-- language="C" -->
* static gchar*
* format_value_callback (GtkScale *scale,
* gdouble value)
*
* <example>
* <title>Creating a search bar</title>
- * |[
+ * |[<!-- language="C" -->
* <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/search-bar.c">
* <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
* </xi:include>
*
* <example>
* <title>Showing the search bar on key presses</title>
- * |[
+ * |[<!-- language="C" -->
* static gboolean
* window_key_press_event_cb (GtkWidget *widget,
* GdkEvent *event,
* need to be aware that settings that are specific to individual widgets
* may not be available before the widget type has been realized at least
* once. The following example demonstrates a way to do this:
- * |[
+ * |[<!-- language="C" -->
* gtk_init (&argc, &argv);
*
* /* make sure the type is realized */
*
* <example>
* <title>Obtaining the window ID of a socket.</title>
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *socket = gtk_socket_new (<!-- -->);
* gtk_widget_show (socket);
* gtk_container_add (GTK_CONTAINER (parent), socket);
*
* <example>
* <title>Using a GtkSpinButton to get an integer</title>
- * |[
+ * |[<!-- language="C" -->
* /* Provides a function to retrieve an integer value from a
* * GtkSpinButton and creates a spin button to model percentage
* * values.
*
* <example>
* <title>Using a GtkSpinButton to get a floating point value</title>
- * |[
+ * |[<!-- language="C" -->
* /* Provides a function to retrieve a floating point value from a
* * GtkSpinButton, and creates a high precision spin button.
* */
*
* The ::output signal can be used to change to formatting
* of the value that is displayed in the spin buttons entry.
- * |[
+ * |[<!-- language="C" -->
* /* show leading zeros */
* static gboolean
* on_output (GtkSpinButton *spin,
* </para>
* <example>
* <title>Using an enumeration to identify animatable regions</title>
- * |[
+ * |[<!-- language="C" -->
* enum {
* REGION_ENTRY,
* REGION_BUTTON_UP,
* </para>
* <example>
* <title>Using struct pointers to identify animatable regions</title>
- * |[
+ * |[<!-- language="C" -->
* void
* notebook_draw_tab (GtkWidget *widget,
* NotebookPage *page,
* </para>
* <example>
* <title>Triggering a state change animation on a region</title>
- * |[
+ * |[<!-- language="C" -->
* gboolean
* notebook_motion_notify (GtkWidget *widget,
* GdkEventMotion *event)
*
* As a practical example, a #GtkButton notifying a state transition on
* the prelight state:
- * |[
+ * |[<!-- language="C" -->
* gtk_style_context_notify_state_change (context,
* gtk_widget_get_window (widget),
* NULL,
* you need to insert your own key handling between the input method
* and the default key event handling of the #GtkTextView.
*
- * |[
+ * |[<!-- language="C" -->
* static gboolean
* gtk_foo_bar_key_press_event (GtkWidget *widget,
* GdkEventKey *event)
*
* <example>
* <title>Creating two #GtkToggleButton widgets.</title>
- * |[
+ * |[<!-- language="C" -->
* void make_toggles (void) {
* GtkWidget *dialog, *toggle1, *toggle2;
*
* to a #GtkToolPalette. To add a #GtkToolItemGroup to a #GtkToolPalette,
* use gtk_container_add().
*
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *palette, *group;
* GtkToolItem *item;
*
* can be used to get the dragged item in the #GtkWidget::drag-data-received
* signal handler of the drag target.
*
- * |[
+ * |[<!-- language="C" -->
* static void
* passive_canvas_drag_data_received (GtkWidget *widget,
* GdkDragContext *context,
*
* <example>
* <title>Acquiring a #GtkTreeIter-struct</title>
- * |[
+ * |[<!-- language="C" -->
* /* Three ways of getting the iter pointing to the location */
* GtkTreePath *path;
* GtkTreeIter iter;
*
* <example>
* <title>Reading data from a #GtkTreeModel</title>
- * |[
+ * |[<!-- language="C" -->
* enum
* {
* STRING_COLUMN,
* empty. The visible function should therefore take special care of empty
* rows, like in the example below.
*
- * |[
+ * |[<!-- language="C" -->
* static gboolean
* visible_func (GtkTreeModel *model,
* GtkTreeIter *iter,
*
* <example>
* <title>Using a #GtkTreeModelSort</title>
- * |[
+ * |[<!-- language="C" -->
* {
* GtkTreeView *tree_view1;
* GtkTreeView *tree_view2;
*
* <example>
* <title>Accessing the child model of in a selection changed callback</title>
- * |[
+ * |[<!-- language="C" -->
* void
* selection_changed (GtkTreeSelection *selection, gpointer data)
* {
* To do this, you can use gtk_tree_row_reference_new().
*
* To free the return value, use:
- * |[
+ * |[<!-- language="C" -->
* g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
* ]|
*
* Calling
* <literal>gtk_tree_store_insert_with_values (tree_store, iter, position, ...)</literal>
* has the same effect as calling
- * |[
+ * |[<!-- language="C" -->
* gtk_tree_store_insert (tree_store, iter, position);
* gtk_tree_store_set (tree_store, iter, ...);
* ]|
* gtk_tree_view_column_set_attributes() on the newly created #GtkTreeViewColumn.
*
* Here's a simple example:
- * |[
+ * |[<!-- language="C" -->
* enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS };
* ...
* {
* Here are some examples of how a %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget
* generally deals with width-for-height requests, for #GtkWidgetClass.get_preferred_height()
* it will do:
- * |[
+ * |[<!-- language="C" -->
* static void
* foo_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
* {
* And in #GtkWidgetClass.get_preferred_width_for_height() it will simply return
* the minimum and natural width:
*
- * |[
+ * |[<!-- language="C" -->
* static void
* foo_widget_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
* gint *min_width, gint *nat_width)
* be careful to call its virtual methods directly, like this:
* <example>
* <title>Widget calling its own size request method.</title>
- * |[
+ * |[<!-- language="C" -->
* GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget),
* &min, &natural);
* ]|
* last #GtkWidget::drag-leave and if not, treat the drag-motion signal as
* an "enter" signal. Upon an "enter", the handler will typically highlight
* the drop site with gtk_drag_highlight().
- * |[
+ * |[<!-- language="C" -->
* static void
* drag_motion (GtkWidget *widget,
* GdkDragContext *context,
* gdk_drag_context_get_selected_action() before calling
* gtk_drag_finish(), e.g. to implement %GDK_ACTION_ASK as
* shown in the following example:
- * |[
+ * |[<!-- language="C" -->
* void
* drag_data_received (GtkWidget *widget,
* GdkDragContext *context,
* To reliably find the toplevel #GtkWindow, use
* gtk_widget_get_toplevel() and call gtk_widget_is_toplevel()
* on the result.
- * |[
+ * |[<!-- language="C" -->
* GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
* if (gtk_widget_is_toplevel (toplevel))
* {
* builders might want to treat them in a different way.
*
* Here is a simple example:
- * |[
+ * |[<!-- language="C" -->
* gtk_widget_push_composite_child ();
* scrolled_window->hscrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, hadjustment);
* gtk_widget_set_composite_name (scrolled_window->hscrollbar, "hscrollbar");
*
* An example of its usage is:
*
- * |[
+ * |[<!-- language="C" -->
* GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
*
* fevent->focus_change.type = GDK_FOCUS_CHANGE;
* The widget path generation is generally simple:
* <example>
* <title>Defining a button within a window</title>
- * |[
+ * |[<!-- language="C" -->
* {
* GtkWidgetPath *path;
*
*
* <example>
* <title>Defining the first tab widget in a notebook</title>
- * |[
+ * |[<!-- language="C" -->
* {
* GtkWidgetPath *path;
* guint pos;
* to be called when the window has its "final" size, i.e. after calling
* gtk_widget_show_all() on the contents and gtk_window_set_geometry_hints()
* on the window.
- * |[
+ * |[<!-- language="C" -->
* #include <gtk/gtk.h>
*
* static void